package com.huarui.ip.action;

import java.util.HashMap;
import java.util.Map;

import net.sf.json.JSONObject;

import org.ewaf.framework.action.BaseAction;

import com.huarui.ip.service.IpAddressService;
import com.huarui.params.Params;

public class IpAddressAction extends BaseAction{

	private static final long serialVersionUID = -165710895641103684L;

	private Map<String, Object> mesMap;
	
	private String queryParam;
	
	private Integer start;
	
	private IpAddressService ipAddressService;
	
	public Integer getStart() {
		return start;
	}

	public void setStart(Integer start) {
		this.start = start;
	}

	public Map<String, Object> getMesMap() {
		return mesMap;
	}

	public void setMesMap(Map<String, Object> mesMap) {
		this.mesMap = mesMap;
	}
	
	public String getQueryParam() {
		return queryParam;
	}

	public void setQueryParam(String queryParam) {
		this.queryParam = queryParam;
	}

	public void setIpAddressService(IpAddressService ipAddressService) {
		this.ipAddressService = ipAddressService;
	}

	/**
	 * 后台查询
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public String listIpAddress() {
		Map<String, Object> paramsMap = null;
		if(queryParam == null) {
			paramsMap = new HashMap<String, Object>();
		} else {
			JSONObject jo = JSONObject.fromObject(queryParam);
			paramsMap = (Map<String, Object>) JSONObject.toBean(jo, HashMap.class);
		}
		paramsMap.put("start", start == null ? 0 : start);
		paramsMap.put("pageSize", Params.BACKGROUND_PAGE_SIZE);
		mesMap = this.ipAddressService.getIpAddressListByComplex(paramsMap);
		return SUCCESS;
	}
}
